<?php include './application/views/zhs_mobile/header.php';?>

<script type="text/javascript">
function getPhoneVerCd(){
	if($.trim($("#phone").val())== ""){
		document.getElementById("phone_id_1").innerHTML = "请输入手机号";
		return ;
	}
	$.ajax({
		type: "post",
		url: "/reg/apply_phone/",
		data: "phone="+$("#phone").val()+"&captcha="+$("#captcha").val(),
		success: function(ret){
			if(ret.info == 1){
				//TODO 待完善
				document.getElementById("phone_id_1").innerHTML = "已发送,3分钟以后重新获取";
				setTimeout(function(){
					document.getElementById("phone_id_1").innerHTML ="<a href = 'javascript:getPhoneVerCd()'>获取手机验证码</a>";
				},3000*60);
			}else{
				changeImage();
				document.getElementById("phone_id_1").innerHTML =ret.msg;
				setTimeout(function(){
					document.getElementById("phone_id_1").innerHTML ="<a href = 'javascript:getPhoneVerCd()'>获取手机验证码</a>";
				},2000);
			}
		},
		dataType: "json"
	});	
}
function checkPhone(input){
	if(input.value=='请输手机号码'){
		input.value="";
	}
}
function clearText(input){
	if( input.value=='请输入邮箱' || input.value=='请输验证码'|| input.value=='推荐人编码'){
		input.value="";
	}
}
function addText(input,id){
	if(input.value == ""){
		if (id ==2){
			input.value="请输手机号码";
		}else if (id == 3){
			input.value="请输验证码";
		}else if (id == 4){
			input.value="推荐人编码";
		}else if (id == 5){
			input.value="";
		}
	}
}
function formSubmit(){
	document.getElementById("reg_form").submit();
}
function changeImage() {
	document.getElementById("imgCode").src = "/yanzheng/index/?" + Math.random();
}
</script>

<section class="invbd main">
<form id="reg_form" action="/zhs_mobile/reg.html" method="post">
  <input type="hidden" name="act" value="reg"/>
  <ul class="forlogin_ul">
    <!--<li>会员昵称</li>
    <li><input  class="inp" type="text" name = "username" value = "请输入会员昵称" onfocus="clearText(this);" onblur = "addText(this,1)"></li>
    -->
    <li>手机号码</li>
    <li><input class="inp" type="text" name = "phone" value = "请输手机号码" id ="phone" onfocus="checkPhone(this);"  onblur = "addText(this,2)"></li>
    <li>密码</li>
    <li><input class="inp" type="password" name = "password"  onfocus="clearText(this);" ></li>
    <li>确认密码</li>
    <li><input class="inp" type="password" name = "password2"  onfocus="clearText(this);"></li>
     <li>验证码</li>
    <li>
      <input class="inpt" style="margin-left:2px" id="captcha" name="captcha" type="text" value="">
       <span><img src="http://%77%77%77%2E%7A%68%73%6A%72%2E%63%6F%6D/yanzheng" id="imgCode"  onclick="changeImage();"  style="cursor: pointer;width:80px;height:50px;" /></span>
     </li>
     
    <li>手机验证码</li>
    <li><input class="inpt"type="text" name = "verify_code" value = "请输验证码"  onfocus="clearText(this);"  onblur = "addText(this,3)">
    <span id="phone_id_1"><a href = "javascript:getPhoneVerCd()">获取手机验证码</a></span>
    <span id="phone_id_2"></span>
   	</li>
    <li>推荐人编码</li>
    <li><input class="inp" type="text" value="<?php if ($invite) echo $invite; else echo "推荐人编码"?>" name="invite" <?php
			if ($invite) {
				echo("readonly=\"readonly\"");
			}
			?>
       maxlength="12" onfocus="clearText(this);"  onblur = "addText(this,4)"></li>
    <li><a href="javascript:formSubmit();" class="logbtn_1">注册</a></li>
  </ul>   
   </form>
</section>
<?php include './application/views/zhs_mobile/footer.php';?>